//
//  SVUploadProgressView.m
//  ShortVideo-ccinon
//
//  Created by LIN TONG on 2017/7/27.
//  Copyright © 2017年 LIN TONG. All rights reserved.
//

#import "SVUploadProgressView.h"
#import "SVConfig.h"

@interface SVUploadProgressView(){
    UIProgressView *progress;
    UILabel        *stateLabel;
}

@end

@implementation SVUploadProgressView

- (id)init{
    if(self = [super init]){
        self.frame = CGRectMake(0, 0, __SCREEN_WIDTH__, __SCREEN_HEIGHT__);
        self.backgroundColor = UIColorMake(1, 1, 1, 0.6);
        
        progress = [[UIProgressView alloc]initWithFrame:CGRectMake(S(20), 0, __SCREEN_WIDTH__-S(20)*2, S(25))];
        progress.progressTintColor = UIColorMake(27, 106, 240, 1);
        progress.trackTintColor = UIColorMake(241, 241, 241, 1);
        [self addSubview:progress];
        progress.center = CGPointMake(__SCREEN_WIDTH__/2.0, __SCREEN_HEIGHT__/2.0);
        
        stateLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(progress.frame)+S(15),__SCREEN_WIDTH__ , S(20))];
        stateLabel.textColor = [UIColor whiteColor];
        stateLabel.font = Font(11);
        stateLabel.textAlignment = NSTextAlignmentCenter;
        [self addSubview:stateLabel];
    }
    return self;
}

- (void)setDescription:(NSString *)des{
    stateLabel.text = des;
}

- (void)setProgressValue:(float)pv{
    [progress setProgress:pv animated:YES];
    [progress setNeedsDisplay];
}

- (void)show{
    [APPDELEGATE.window addSubview:self];
}

- (void)close{
    [self removeFromSuperview];
}

@end
